home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / RxMUI / Examples / clock.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-05-24  |  4.5 KB  |  150 lines

  1. /*clock.rexx 1.0 (11.11.2000)*/
  2.  
  3. signal on halt
  4. signal on break_c
  5. call init
  6. call CreateApp
  7. call handleApp
  8. /* never reached */
  9. /***********************************************************************/
  10. init:procedure expose global.
  11.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  12.     if AddLibrary("rxmui.library")~=0 then exit
  13.  
  14.     global.tim=CreateTimer()
  15.     global.ts=TimerSignal(global.tim)
  16.  
  17.     global.DateFormats.0="%A %e %b %Y"
  18.     global.DateFormats.1="%A %b %e %Y"
  19.     global.DateFormats.2="%e/%m/%Y"
  20.     global.DateFormats.3="%m/%e/%Y"
  21.  
  22.     global.TimeFormats.0="%H:%M:%S"
  23.     global.TimeFormats.1="%I:%M:%S %p"
  24.  
  25.     global.DateFormat=0
  26.     global.TimeFormat=0
  27.  
  28.     global.NewDateFormat=0
  29.     global.NewTimeFormat=0
  30.  
  31.     global.ChangeDateFormat=0
  32.     global.ChangeTimeFormat=0
  33.  
  34.     return
  35. /***********************************************************************/
  36. HandleApp: procedure expose global.
  37.     ctrl_c=2**12
  38.     sig=or(ctrl_c,global.ts)
  39.     call StartTimer(global.tim,0,900000)
  40.     do forever
  41.         call NewHandle("app","h",sig)
  42.         if and(h.signals,ctrl_c)>0 then exit
  43.         if and(h.signals,global.ts)>0 then do
  44.             call RefreshTime()
  45.             call StartTimer(global.tim,0,900000)
  46.         end
  47.         if h.EventFlag then
  48.             select
  49.                 when h.event="QUIT" then exit
  50.                 otherwise interpret h.event
  51.             end
  52.         end
  53.     end
  54.     /* never reached */
  55. /***********************************************************************/
  56. CreateApp: procedure expose global.
  57.  
  58.     app.title="Clock"
  59.     app.version="$VER: Clock 1.0 (20.7.2000)"
  60.     app.copyright="©2000 by alfie"
  61.     app.author="alfie"
  62.     app.description="Clock"
  63.     app.base="CLOCK"
  64.     app.SubWindow="win"
  65.  
  66.      win.ID="MAIN"
  67.      win.title="Clock"
  68.      win.contents="mgroup"
  69.  
  70.       call child("mgroup","vg","group")
  71.        call child("vg","popd","popobject")
  72.         popd.object="popdlv"
  73.          popdlv.class="listview"
  74.          popdlv.list="dflist"
  75.           dflist.frame="inputlist"
  76.            dflist.0="DayName DayNum MonthName Year"
  77.            dflist.1="DayName Month DayNum Year"
  78.            dflist.2="DayName/MonthName/Year"
  79.            dflist.3="MonthName/DayName/Year"
  80.         popd.string=text("date","")
  81.         popd.button=MakeObj("","Imagebutton","popup")
  82.         popd.toggle=1
  83.  
  84.        call child("vg","popt","popobject")
  85.         popt.object="poptlv"
  86.          poptlv.class="listview"
  87.          poptlv.list="tflist"
  88.           tflist.frame="inputlist"
  89.            tflist.0="24 hours"
  90.            tflist.1="Am/Pm"
  91.         popt.string=text("time","")
  92.         popt.button=MakeObj("","Imagebutton","popup")
  93.         popt.toggle=1
  94.  
  95.     res=NewObj("application","app")
  96.     if res~=0 then call err(res)
  97.  
  98.     call notify("win","CloseRequest",1,"app","ReturnID","QUIT")
  99.  
  100.     call notify("dflist","doubleclick","everytime","popd","close",1)
  101.     call notify("dflist","doubleclick","everytime","app","setvar","GLOBAL.CHANGEDATEFORMAT")
  102.     call notify("dflist","active","everytime","app","setvar","GLOBAL.NEWDATEFORMAT")
  103.  
  104.     call notify("tflist","doubleclick","everytime","popt","close",1)
  105.     call notify("tflist","doubleclick","everytime","app","setvar","GLOBAL.CHANGETIMEFORMAT")
  106.     call notify("tflist","active","everytime","app","setvar","GLOBAL.NEWTIMEFORMAT")
  107.  
  108.     call RefreshTime()
  109.     call set("win","open",1)
  110.     if ~xget("win","open") then do
  111.         say "can't open window"
  112.         exit
  113.     end
  114.     return
  115. /***********************************************************************/
  116. halt:
  117. break_c:
  118.     exit
  119. /**************************************************************************/
  120. RefreshTime: procedure expose global.
  121.     call GetDate("NOW")
  122.  
  123.     if global.ChangeTimeFormat then do
  124.         global.ChangeTimeFormat=0
  125.         global.TimeFormat=global.NewTimeFormat
  126.     end
  127.     tf=global.TimeFormat
  128.     time=FormatDate("NOW",global.TimeFormats.tf)
  129.     call set("time","contents",time)
  130.  
  131.     if global.ChangeDateFormat then do
  132.         global.ChangeDateFormat=0
  133.         global.DateFormat=global.NewDateFormat
  134.     end
  135.     df=global.DateFormat
  136.     date=FormatDate("NOW",global.DateFormats.df)
  137.     if global.OldDate~=date then do
  138.         call set("date","contents",date)
  139.         global.OldDate=date
  140.     end
  141.     return
  142. /***************************************************************************/
  143. err: procedure expose sigl RxMUIError
  144. parse arg res
  145.     msg = ProgramName()":" GetRxMUIString(res) "in line" sigl-1
  146.     if RxMUIError~="RXMUIERROR" then msg = msg "["RxMUIError"]"
  147.     say msg
  148.     exit
  149. /***********************************************************************/
  150.